﻿using System;
using System.Windows.Data;

namespace CodeBadger.GasMileage.Converters
{
    public class TextFormatConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Format(value, parameter);
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Format(value, parameter);
        }

        static object Format(object value, object param)
        {
            return value == null 
                ? value 
                : string.Format(param.ToString(), value);
        }
    }
}
